<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="#">首页</a>
                        </li>
                        <li class="active">
                            <a href="javascript:void(0)" class="current"><?php if($type == 1):?>草稿箱<?php else:?>群发历史记录<?php endif;?></a>
                        </li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->
                <!-- Page Header -->
                <div class="container-fluid">
                <!-- /Page Header -->
                <!-- Page Body -->
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="tab-content tabs-flat no-padding">
                                <div id="visits" class="tab-pane active animated fadeInUp">
                                    <div class="row">
                                        <div class="col-lg-12 chart-container">
                                            <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                                                <div class="widget-body">
                                                      <table class="table table-bordered">
                                                        <thead>
                                                          <tr >
                                                              <th style="width: 100px;">
                                                                <?php if($order=='desc'):?>
                                                                 <a href="<?= BASEURL; ?>luckydog/emailsender/emailsender_history?sortname=usertype&order=asc&type=<?=$type?>">用户类型↓</a>
                                                                <?php elseif($order=='asc'):?>
                                                                 <a href="<?= BASEURL; ?>luckydog/emailsender/emailsender_history?sortname=usertype&order=desc&type=<?=$type?>">用户类型↑</a>       
                                                                <?php endif;?>
                                                              </th>
                                                            <th>主题</th>
                                                              <th style="width: 150px;">
                                                                <?php if($order=='desc'):?>
                                                                 <a href="<?= BASEURL; ?>luckydog/emailsender/emailsender_history?sortname=addtime&order=asc&type=<?=$type?>">发布日期↓</a>
                                                                <?php elseif($order=='asc'):?>
                                                                 <a href="<?= BASEURL; ?>luckydog/emailsender/emailsender_history?sortname=addtime&order=desc&type=<?=$type?>">发布日期↑</a>
                                                                <?php endif;?>
                                                              </th>
                                                              <?php if($this->session->userdata('action_list') == "all" && $type == 1):?><th style="width: 50px;">删除草稿</th><?php endif;?>           
                                                          </tr>
                                                        </thead>
                                                        <tbody>
                                                          <?php foreach ($history_list as $row):?>
                                                              <tr > 
                                                                <td><?=$row['tosendtype']?> </td>        
                                                                <td style="cursor: pointer;" <?php if($type == 1):?> onclick="window.location.href='<?= BASEURL; ?>luckydog/emailsender?draftid=<?=$row['id']?>&type=1';" <?php else:?> class="test_message"  data-value="<?=$row['id']?>" <?php endif;?>><?= $row['subject']?></td>
                                                                <td style="height: 30px;"><?php if(date('d',$row['addtime']) == date('d',time())){echo "今天".date('H:i',$row['addtime']);}elseif(date('Y',$row['addtime']) == date('Y',time())){echo date('m月d日',$row['addtime']);}else{echo date('Y/m/d',$row['addtime']);}?>
                                                                </td>
                                                                <?php if($this->session->userdata('action_list') == "all" && $type == 1):?>
                                                                <td >
                                                                  <a href="javascript:void(0);" onclick="del_draft(<?=$row['id']?>)">删除</a>
                                                                </td><?php endif;?>
                                                            </tr>
                                                      <?php endforeach;?>
                                                            <tr><td colspan="2"><?=$page_links?></td></tr>
                                                        </tbody>
                                                      </table>
                                                </div>
                                            </div>
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
//测试弹出
$("td").css("vertical-align","middle");
$(document).ready(function(){
     var objPos = mousePosition('event'); 
     $(".test_message").live('click',function(){
        var id = $(this).attr("data-value");
        $.post("<?=BASEURL?>luckydog/emailsender/emailsender_content",{id:id},function(data){
            messContent='<div class="content" style="padding:5px 5px;width:700px;overflow-x:hidden; overflow-y:auto;overflow-x:auto; height:300px;">'
        	          +data.content		          
          		      +'</div>';
            showMessageBox('邮件内容',messContent,objPos,400);	       
    },'json');
 });
});
function del_draft(id) {
    if (confirm("确定要删除吗？") == true) {
  	  $.post('<?=BASEURL; ?>luckydog/emailsender/del_draft', {'id':id}, function(res) {
            if (res == 1) {
                alert('成功');
                window.location.reload();
            } else {
                alert('失败');
            }
        });
    }
}

</script>